#include<iostream>
#include <bits/stdc++.h>
#include <vector>

#include <typeinfo>
#include <functional>

using namespace std;

template<typename T, typename CompareFunc>
void quickSort(vector<T>& array, int start, int end, CompareFunc compare) {
    int l = start, r = end, p = start;
    if (end <= start) return;

    auto swap = [&array](int a, int b) {T tmp; tmp = array[a], array[a] = array[b], array[b] = tmp;};

    while (l < r) {
        while (l < r && compare(array[r], array[p])) r--;
        while (l < r && compare(array[p], array[l])) l++;
        swap(l, r);
    }

    swap(l, p);

    quickSort(array, start, l-1, compare);
    quickSort(array, l+1, end, compare);
}

int main() {
    //vector<int> nums = {1,3,3,4,6,2,33,7,9,0,-1};
    vector<string> nums = {"aaa", "aa", "a", "aaaa", "a"};
    quickSort(nums, 0, nums.size()-1, [](const string& a, const string& b) { return a >= b;});

    for(size_t i = 0; i < nums.size(); ++i) {
        std::cout << nums[i] << ", ";
    }
    std::cout << std::endl;
    std::cout << "Hello World!" << std::endl;
    return 0;
}